package com.hardson.toolkit.util;

import java.awt.Component;
import java.awt.HeadlessException;
import java.awt.Image;
import java.io.File;

import javax.swing.JDialog;
import javax.swing.JFileChooser;

public class HardsonFileChooser extends JFileChooser {

	private Image iconImage;

	public HardsonFileChooser(Image iconImage) {
		this.iconImage = iconImage;
	}

	public HardsonFileChooser(String currentDirPath, Image iconImage) {
		super(currentDirPath);
		this.iconImage = iconImage;
	}

	public HardsonFileChooser(File currentDir, Image iconImage) {
		super(currentDir);
		this.iconImage = iconImage;
	}

	private static final long serialVersionUID = 1L;

	@Override
	protected JDialog createDialog(Component parent) throws HeadlessException {
		JDialog dialog = super.createDialog(parent);
		if (this.iconImage != null) {
			dialog.setIconImage(this.iconImage);
		}
		return dialog;
	}
}
